package com.ryan.mms.privilage.action;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ryan.framework.action.BaseAction;
import com.ryan.mms.privilage.dto.OperatorDto;
import com.ryan.mms.privilage.model.Operator;
import com.ryan.mms.privilage.service.OperatorService;

@Component
public class LoginAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private final Logger logger = Logger.getLogger(this.getClass());
	private OperatorDto operatorDto;
	
    @Autowired
	private OperatorService<OperatorDto,Operator,Long> operatorService;

	public String login(){
		try{
			OperatorDto operatorResult = operatorService.login(operatorDto);
			if(null!=operatorResult){
				return SUCCESS;
			}else{
				throw new Exception("login fail!");
			}
		}catch(Exception e){
			logger.error(e.getMessage(), e);
			return ERROR;
		}
	}
	
	public OperatorDto getOperatorDto() {
		return operatorDto;
	}


	public void setOperatorDto(OperatorDto operatorDto) {
		this.operatorDto = operatorDto;
	}


	public void setOperatorService(
			OperatorService<OperatorDto, Operator, Long> operatorService) {
		this.operatorService = operatorService;
	}

}
